package cn.wsalix.login.entity;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import cn.anlaser.entity.SimpleEntity;
import cn.wsalix.admin.entity.SysUser;

@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "QQ_USER")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@EntityListeners({ AuditingEntityListener.class })
@Data
@EqualsAndHashCode(callSuper = false)
public class QQUser extends SimpleEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1361814296554121100L;

	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_QQUSER_USER"), name = "USER_ID")
	private SysUser user;// 支付账号
	
	private String openId;
	private String ret;
	private String is_lost;
	private String nickname;
	private String gender;
	private String country;
	private String province;
	private String city;
	private String figureurl;
	
	@OneToOne(optional = true, cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
	@PrimaryKeyJoinColumn(name = "ID", referencedColumnName = "ID")
	private QQAccessToken qqAccessToken;// 支付账号
}
